package com.gxa.controller;


import com.gxa.common.LayR;
import com.gxa.common.R;
import com.gxa.param.OrderParam;
import com.gxa.pojo.Contract;
import com.gxa.pojo.Order;
import com.gxa.service.OrderService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/order")
public class OrderController {



    @Autowired
    public OrderService orderService;




    @GetMapping("select/list/page")
    public String list(){
        return "order/order-list";
    }


    @PostMapping("select/list/data")
    @ResponseBody
    public LayR listData(OrderParam param){
        return orderService.list(param);
    }


    @PostMapping("/delete")
    @ResponseBody
    public R delete(@RequestParam("ids[]") String[] ids){
        return orderService.deleteAll(ids);
    }



    @GetMapping("put/list/page")
    public String addlist(){
        return "order/order-put";
    }

    @PostMapping("put/list/data")
    @ResponseBody
    public LayR CustomerlistData(OrderParam param){
        return orderService.customerList(param);
    }



    @GetMapping("/add/page")
    public String addPage(@Param("id") Integer id, HttpSession session)
    {
        session.setAttribute("order",orderService.findById(id));
        return "order/order-add";
    }


    @PostMapping("/goods/data")
    @ResponseBody
    public LayR getList(){
        return orderService.list();

    }



    @GetMapping("/edit/page")
    public String editPage(@Param("id") Integer id, HttpSession session)
    {
        session.setAttribute("order",orderService.findById(id));
        return "order/order-edit";
    }


    @PostMapping("/add/do")
    @ResponseBody
    public LayR add(Order order){
        return orderService.add(order);
    }

}
